
<script>
    // typeof数据类型,可以返还的值 number string boolean object undefined  function
    var num = undefined;  
    console.log(typeof(num));   /*undefined*/

    var num = null;
    console.log(typeof(num));  
    var num = [];
    console.log(typeof(num)); 
    var num={};
    console.log(typeof(num))/*object 返回对象*/

    var num = true;
    console.log(typeof(num));  /*boolean 返回布尔值*/

    var num = function(){}
    console.log(typeof(num))  /*function 返回函数值*/

    // 字符串之间可以计算
    var num = 1 * '1';
    console.log(typeof(num) + ': ' + num);
    var num = '2' * '1';
    console.log(typeof(num) + ':' + num)
    var num = 1 - '1';
    console.log(typeof(num) + ': ' + num);


</script>


number转化为数字
<script>
    // 将字符串‘123’转换成数字123
    var num =Number('123'); /*将字符串‘123’转换成数字123并且返还给num, var num = 123;*/
    console.log(typeof(num) + ':' + num);  

    var num = Number(true);
    console.log(typeof(num) + '' + num); /*布尔值ture转化为数字为1*/

    var num =Number(null);
    console.log(typeof(num) + ':' + num); /*null转化为数字是0*/

    var num = Number(undefined);
    console.log(typeof(num) + ':' + num); /*undefined转化为数字是NaN*/
</script>
 
